package com.one.enums;

import com.one.dto.EnumResult;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public enum SexEnum {
    BOY("0","男"),GIRL("1","女"),UNKNOW("2","保密");

    private String key;
    private String value;
    SexEnum(String key, String value) {
        this.key = key;
        this.value = value;
    }
    public static String getEnumValue(String key) {
        SexEnum[] sexEnums = SexEnum.values();
        for (SexEnum sexEnum : sexEnums) {
            if (sexEnum.getKey().equals(key)) {
                return sexEnum.getValue();
            }
        }
        return null;
    }
    public static List<EnumResult> getEnumList() {
        SexEnum[] sexEnums = SexEnum.values();
        List<EnumResult> result = Stream.of(sexEnums).map(
                entry -> new EnumResult(entry.getKey(), entry.getValue())).collect(Collectors.toList());
        return result;
    }
    public String getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }
}
